package cn.edu.zzuli.wechat.user.mapper;

import cn.edu.zzuli.model.dto.OfferOrderDto;
import cn.edu.zzuli.model.dto.RunOrderDto;
import cn.edu.zzuli.model.entity.RunOrder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface RunOrderMapper extends BaseMapper<RunOrder> {

    //查询用户的接单列表依据条件
    @Select({"<script>",
            "SELECT ouid,roid as id,type,offer_order.`title`,run_time,finish_time,run_order.`status`" +
            "from run_order join offer_order on oid = roid and ruid = #{uid}",
            "<if test='type!=null'>"
            , "and type = #{type}"
            , "</if>"
            ,"order by status"
            ,"</script>"})
    Page<RunOrderDto> queryList(Page<RunOrderDto> page,@Param("uid") Integer uid, @Param("type")String type);

    //获取详细信息
    @Select("select roid as id,ruid,nick_name,run_time,finish_time from run_order join user on ruid = uid and roid = #{id}")
    RunOrderDto findById(int id);
}
